#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File    : timer.py
@Time    : 2023/01/27 17:28:24
@Author  : 郭瑞强
@Contact : sunraing@126.com
@Version : 0.1
@License : BSD 3-Clause License
@Desc    : 简易计时器，毫秒级
"""
import time


def timer(func):
    def func_in(*args, **kwargs):
        start_time = time.time_ns()
        func(*args, **kwargs)
        end_time = time.time_ns()

        print(
            "{0} Spend_time:{1:.2f} ms".format(
                func.__name__, (end_time - start_time) / 1000_000
            )
        )

    return func_in
